package name.bingo;/**
 * create by yanbing on 2018/11/21 15:16
 */

/**
 *
 * @param:
 * @return:
 * @auther: yanbing
 * @date: 2018/11/21 15：16
 **/
public class Test {
    public static void main(String[] args) {
        test1();

    }
    public static void test1(){
        double netValue=1;
        double money=100;
        double lastNum=money/netValue;
        double feate=0.02;
        double bias=0.008;
        double sumMoney=money;
        double relMoney=money;
        double lasrPrice=netValue;//

        System.out.println("sumMoney:"+sumMoney);
        for(int i=1;i<11;i++){
            double newPrice=lasrPrice*(1-feate);
            double targetPrice=newPrice*(1+bias);
            //targetPrice=((lastNum*lasrPrice)+(newPrice*newNum))/(lastNum+newNum);
            double newNum=lastNum*(lasrPrice-targetPrice)/(targetPrice-newPrice);
            System.out.println(i+":"+newPrice);
            System.out.println(i+"----"+targetPrice+":"+newNum);
            System.out.println(i+"++++"+targetPrice*newNum);
            lasrPrice=newPrice;
            lastNum=newNum;
            sumMoney +=lastNum*lasrPrice;
            relMoney=relMoney*(1-feate)+lastNum*lasrPrice;
            System.out.println(i+"===="+relMoney);
            System.out.println(i+"========"+sumMoney);
        }
        System.out.println("relMoney:"+relMoney);
        System.out.println("sumMoney:"+sumMoney);
    }
}
